<%@page import="com.wframe.framework.util.UploadUtil"%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/page-base.tld" prefix="w"%>
<%String path=request.getContextPath(); request.setAttribute("fileserver", UploadUtil.getConfig().getDownserver());%>
<script src="<%=path %>/plugins/cityselect/jquery.cityselect.js" type="text/javascript"></script>
<div class="easyui-tabs" id="pedit_tabs" data-options="fit:true,border:false,tools:'#productedittool'">
	<div title="基本信息" class="ui-formContent">
		<form method="post" action="/user/UserPage@update.page" class="pageForm">
			<div class="ui-formContent" style="padding:10px 30px;">
				<div class="headT"><span></span><label>基本信息</label></div>
				<table width="80%" cellpadding="2" cellspacing="2">
					<tr>
						<td width="90">账号：</td><td width="30%"><w:text id="loginname"  bind="bean.loginname" onblur="javascript:checkexistaccount();" /></td>
						<td width="90">昵称：</td><td><w:text bind="bean.nickname"/></td>
					</tr>
					<tr>
						<td width="90">密码：</td><td width="30%"><w:text id="loginpwd" type="password" bind="bean.loginpwd"/></td>
						<td>性别：</td><td><w:radio bind="bean.sex" value="1" text="男"/><w:radio bind="bean.sex" value="2" text="女"/></td>
					</tr>
					<tr>
						<td>手机号码：</td><td><w:text id="phone" bind="bean.phone"/></td>
						<td>E-mail：</td><td><w:text bind="bean.email"/></td>
					</tr>
					<tr>
						<td>客户等级：</td><td><select name="bean.grade" style="width:200px;height:30px;"><option value=""></option><w:options bind="bean.grade" dict="UserGrade"/></select></td>
						<td>客户分组：</td><td><select name="bean.usergroup" style="width:200px;height:30px;"><option value=""></option><w:options bind="bean.usergroup" dict="UserGroup"/></select></td>
					</tr>
					<tr>
						<td>价格等级：</td><td><select name="bean.pricegrade" style="width:200px;height:30px;"><option value=""></option><w:options bind="bean.pricegrade" dict="PriceGrade"/></select></td>
						<td>是否审核：</td><td><w:radio bind="bean.authstate" value="2" text="立即通过"/><w:radio bind="bean.authstate" value="1" text="暂不通过"/></td>
					</tr>
				</table>

				<div class="line8"></div><div class="line8"></div>
				<div class="headT"><span></span><label>企业信息</label></div>
				<table width="80%" cellpadding="2" cellspacing="2">
					<tr>
						<td width="90">企业名称：</td><td width="30%"><w:text bind="company.name"/></td>
						<td width="90">企业类型：</td><td><select name="company.type" style="width:200px;height:30px;"><option value=""></option><w:options bind="company.type" dict="CompanyType"/></select></td>
					</tr>
					<tr>
						<td>营业执照：</td><td colspan="3"><w:text bind="company.idnum" style="width:360px"/></td><td></td><td></td>
					</tr>
					<tr>
						<td>联系人：</td><td><w:text bind="company.contacts"/></td>
						<td>联系号码：</td><td><w:text bind="company.phone"/></td>
					</tr>
					<tr>
						<td>所属区域：</td><td colspan="3" id="usercompanyaddress">
							<table>
								<tr>
									<td>
										<select name="company.province" class="prov" style="width:120px;border:0px;height:30px;"><option value="">选择省份</option></select>
									</td><td><select name="company.city" class="city" style="width:120px;border:0px;height:30px;">
									<option value="">选择城市</option>
								</select>
								</td><td><select name="company.region" class="dist" style="width:120px;border:0px;height:30px;">
									<option value="">选择地区</option>
								</select>
								</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>详细地址：</td><td><w:text bind="company.address" style="width:360px"/></td>
					</tr>
				</table>
				<div class="line8"></div>
			</div>
		</form>
		<div style="margin-left:100px">
			<a href="javascript:;" class="easyui-linkbutton marginR16" iconCls="icon_save" onclick="checkAndSubmitAddUserForm();">保 存</a>
			<a href="javascript:;" class="easyui-linkbutton" iconCls="icon_cancel" onclick="$w.closeCurrWin()">取 消</a>
		</div>
		<div class="line8"></div><div class="line8"></div>
		<div class="line8"></div><div class="line8"></div>
	</div>
	<div title="资质管理" class="ui-formContent">
		<w:switch>
			<w:case bind="#qullist.size()>0">
				<div style="margin:20px">
					<table cellpadding="1" cellspacing="1" style="background:#dddddd">
						<tr class="ui-formContent">
							<td align="center" style="width:180px" height="30">资质类型</td>
							<td align="center" style="width:180px">证件号码</td>
							<td align="center" style="width:240px">证件有效期</td>
							<td align="center" style="width:170px">图片</td>
						</tr
						<w:iterate bind="#qullist" id="info">
							<tr>
								<td align="center" class="ui-formContent"><w:write bind="#info.type" dict="CerType"/></td>
								<td align="center" class="ui-formContent"><w:write bind="#info.idnum"/></td>
								<td align="center" class="ui-formContent"><w:write bind="#info.validity_start"/>至<w:write bind="#info.validity_end"/></td>
								<td align="center" class="ui-formContent"><w:notEqual bind="#info.img" value=""><img src="${fileserver }<w:write bind="#info.img"/>" style="width:150px"></w:notEqual> </td>
							</tr>
						</w:iterate>
					</table>
				</div>
			</w:case>
			<w:else>
				<div style="padding-left:50px;padding-top:20px;" class="nodata">没有上传相关资质信息！</div>
			</w:else>
		</w:switch>

	</div>
</div>
<script>
    $("#usercompanyaddress").citySelect({prov:'<w:write bind="company.province"/>',city:'<w:write bind="company.city"/>',dist:'<w:write bind="company.region"/>',required:false});

    function checkAndSubmitAddUserForm(){

        $("#loginname").val( "" + $("#loginname").val().trim());
        $("#loginpwd").val( "" + $("#loginpwd").val().trim());
        $("#phone").val( "" + $("#phone").val().trim());

        var loginname = $("#loginname").val();
        var loginpwd = $("#loginpwd").val();
        var phone = $("#phone").val();

        if(loginname==""){
            alert("账号不能为空");
            return false;
		}
        if(loginname.length < 6 ){
            alert("账号至少六位");
            return false;
        }
        if(loginpwd==""){
            alert("密码不能为空");
            return false;
        }
        if(loginpwd.length < 6 ){
            alert("密码至少六位");
            return false;
        }
        if(phone==""){
            alert("手机号码不能为空");
            return false;
        }
        if(phone.length != 11 ){
            alert("手机号码长度有误");
            return false;
        }

        $.getJSON("<%=path %>/user/checkAccount",{"loginname":loginname},function(ret){
            if(ret.Data.exist=='true') {
                alert("该账号已被注册!");
            }else{
                $w.doWinForm();
            }
		});

	}

    function checkexistaccount(backfun){
        $("#loginname").val( "" + $("#loginname").val().trim());
        var loginname = $("#loginname").val();

        if( loginname.length < 6 ){
            alert("账号至少六位字符");
            return;
        }

        $.getJSON("<%=path %>/user/checkAccount",{"loginname":loginname},function(ret){
			if(ret.Data.exist=='true') {
				alert("该账号已被注册!");
			}else{
				if(backfun)backfun();
			}
        });
    }
</script>